﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;



namespace SalesVMT
{
    public partial class frmConfig : Form
    {
        public frmConfig()
        {
            InitializeComponent();

            txtServer.Text = Properties.Settings.Default.Setting1;
            txtDB.Text = Properties.Settings.Default.Setting2;
            txtUser.Text = Properties.Settings.Default.Setting3;
            txtPwd.Text = Properties.Settings.Default.Setting4;
            txtServer.TabStop = false;
        }
        private bool CheckValid()
        {
            return true;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.Setting1 = txtServer.Text;
            Properties.Settings.Default.Setting2 = txtDB.Text;
            Properties.Settings.Default.Setting3 = txtUser.Text;
            Properties.Settings.Default.Setting4 = txtPwd.Text;

            Properties.Settings.Default.SalesVMTConn = "Data Source=" + txtServer.Text + ";Initial Catalog=" + txtDB.Text + "; uid=" + txtUser.Text + "; pwd=" + txtPwd.Text + "";
            frmLogin f = new frmLogin();
            if (f.ShowDialog(this) == DialogResult.OK)
            {
                Properties.Settings.Default.Save();
                Program.taskbarNotifier.Show(Message.Info, "Kết nối thành công,\nhãy đăng nhập lại để sử dụng!", UIParamater.TimeToShow, UIParamater.TimeToStay, UIParamater.TimeToHide);
                this.Close();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}